package com.wxyzz.canteenadmin.canteencard.sale.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wxyzz.canteenadmin.canteencard.sale.mapper.SaleMapper;
import com.wxyzz.canteenadmin.canteencard.sale.param.SaleParam;
import com.wxyzz.canteenadmin.canteencard.sale.service.SaleService;
import com.wxyzz.canteenadmin.canteencard.sale.vo.SaleVo;
import com.wxyzz.canteenadmin.vip.entity.member.Member;
import com.wxyzz.canteencommon.entity.card.sale.Sale;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * --- 代码敲烂 月薪过万 ---
 *
 * @author zhouhaoyu
 * @date 2024/10/11
 * @desc
 */
@Service
public class SaleServiceImpl implements SaleService {

    @Resource
    private SaleMapper saleMapper;
    @Override
    public PageInfo<SaleVo> findAllSaleAndPage(SaleParam saleParam) {
        PageHelper.startPage(saleParam.getPageNum(),saleParam.getPageSize());
        List<SaleVo> salesList =  saleMapper.selectAllSale(saleParam);
        System.out.println(salesList);
        PageInfo<SaleVo> pageInfo = new PageInfo<>(salesList);

        return pageInfo;
    }

    @Override
    public void delSaleById(Integer saleId) {
        saleMapper.deleteById(saleId);
    }

    @Override
    public List<Member> findAllMember() {
        List<Member> memberList = saleMapper.selectAllMember();
        return memberList;
    }

    @Override
    public Member findMemberById(Integer memberId) {

        return saleMapper.selectMemberById(memberId);
    }

    @Override
    public void insertSale(Sale sale) {
        saleMapper.insertSale(sale);
    }
}
